

country.drop <- unique(epr.final$countryname)
model.4.i.p.jack <- data.frame(matrix(NA,nrow=length(country.drop),ncol=3))


for(i in 1:length(country.drop)){
model.4.i.p <- plm(inclprop~past.conference.number.noIR + incidence_flag + mad_gdppc + p_polity2 + gwf_personal + gwf_party + gwf_military+first.leader+leader.size+leader.time.in.office+leader.historical.count+timeSinceLastCoup, data=epr.final[is.na(epr.final$inclprop)==FALSE & epr.final$countryname!=country.drop[i],],index=c("countries_gwid","year"),model="within",effect="twoways")
model.4.i.p.jack[i,1] <- country.drop[i]
model.4.i.p.jack[i,2] <- summary(model.4.i.p)$coefficients[1,1]
model.4.i.p.jack[i,3] <- summary(model.4.i.p)$coefficients[1,2]
}



country.drop <- unique(epr.final$countryname)
model.4.i.pop.jack <- data.frame(matrix(NA,nrow=length(country.drop),ncol=3))

for(i in 1:length(country.drop)){
model.4.i.pop <- plm(legippop~past.conference.number.noIR + incidence_flag + mad_gdppc + p_polity2 + gwf_personal + gwf_party + gwf_military+first.leader+leader.size+leader.time.in.office+leader.historical.count+timeSinceLastCoup, data=epr.final[is.na(epr.final$inclprop)==FALSE & epr.final$countryname!=country.drop[i],],index=c("countries_gwid","year"),model="within",effect="twoways")
model.4.i.pop.jack[i,1] <- country.drop[i]
model.4.i.pop.jack[i,2] <- summary(model.4.i.pop)$coefficients[1,1]
model.4.i.pop.jack[i,3] <- summary(model.4.i.pop)$coefficients[1,2]
}


names(model.4.i.p.jack) <- c("country","estimate","se")
names(model.4.i.pop.jack) <- c("country","estimate","se")




###
country.drop <- unique(epr.final$countryname)
model.4.i.p.jack.d <- data.frame(matrix(NA,nrow=length(country.drop),ncol=3))


for(i in 1:length(country.drop)){
model.4.i.p <- plm(inclprop~past.conference.presence.noIR + incidence_flag + mad_gdppc + p_polity2 + gwf_personal + gwf_party + gwf_military+first.leader+leader.size+leader.time.in.office+leader.historical.count+timeSinceLastCoup, data=epr.final[is.na(epr.final$inclprop)==FALSE & epr.final$countryname!=country.drop[i],],index=c("countries_gwid","year"),model="within",effect="twoways")
model.4.i.p.jack.d[i,1] <- country.drop[i]
model.4.i.p.jack.d[i,2] <- summary(model.4.i.p)$coefficients[1,1]
model.4.i.p.jack.d[i,3] <- summary(model.4.i.p)$coefficients[1,2]
}



country.drop <- unique(epr.final$countryname)
model.4.i.pop.jack.d <- data.frame(matrix(NA,nrow=length(country.drop),ncol=3))

for(i in 1:length(country.drop)){
model.4.i.pop <- plm(legippop~past.conference.presence.noIR + incidence_flag + mad_gdppc + p_polity2 + gwf_personal + gwf_party + gwf_military+first.leader+leader.size+leader.time.in.office+leader.historical.count+timeSinceLastCoup, data=epr.final[is.na(epr.final$inclprop)==FALSE & epr.final$countryname!=country.drop[i],],index=c("countries_gwid","year"),model="within",effect="twoways")
model.4.i.pop.jack.d[i,1] <- country.drop[i]
model.4.i.pop.jack.d[i,2] <- summary(model.4.i.pop)$coefficients[1,1]
model.4.i.pop.jack.d[i,3] <- summary(model.4.i.pop)$coefficients[1,2]
}


names(model.4.i.p.jack.d) <- c("country","estimate","se")
names(model.4.i.pop.jack.d) <- c("country","estimate","se")







setwd(pathOUT)

p <- ggplot(model.4.i.p.jack, aes(x=country, y=estimate, ymin = estimate - 1.96*se, ymax = estimate + 1.96*se)) +
		ylim(0,0.2)+
		geom_pointrange()+
			coord_flip()+
			labs(title = "",
             x = "Countries",
             y = "Estimate")+ theme_bw() + geom_hline(yintercept=0,linetype="dashed")
             
             ggsave("jack_p.pdf",p,width = 18, height = 13*1.63, units = c("cm"))


p <- ggplot(model.4.i.pop.jack, aes(x=country, y=estimate, ymin = estimate - 1.96*se, ymax = estimate + 1.96*se)) +
		ylim(0,0.2)+
		geom_pointrange()+
			coord_flip()+
			labs(title = "",
             x = "Countries",
             y = "Estimate")+ theme_bw() + geom_hline(yintercept=0,linetype="dashed")
             
             ggsave("jack_pop.pdf",p,width = 18, height = 13*1.63, units = c("cm"))

             
p <- ggplot(model.4.i.p.jack.d, aes(x=country, y=estimate, ymin = estimate - 1.96*se, ymax = estimate + 1.96*se)) +
		ylim(0,0.35)+
		geom_pointrange()+
			coord_flip()+
			labs(title = "",
             x = "Countries",
             y = "Estimate")+ theme_bw() + geom_hline(yintercept=0,linetype="dashed")
             
             ggsave("jack_p_d.pdf",p,width = 18, height = 13*1.63, units = c("cm"))


p <- ggplot(model.4.i.pop.jack.d, aes(x=country, y=estimate, ymin = estimate - 1.96*se, ymax = estimate + 1.96*se)) +
		ylim(0,0.35)+
		geom_pointrange()+
			coord_flip()+
			labs(title = "",
             x = "Countries",
             y = "Estimate")+ theme_bw() + geom_hline(yintercept=0,linetype="dashed")
             
             ggsave("jack_pop_d.pdf",p,width = 18, height = 13*1.63, units = c("cm"))

